<template>
  <a-layout id="home">
    <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
      <div class="logo">{{collapsed?"问卷":"宝能问卷管理"}}</div>
      <a-menu theme="dark" mode="inline" :default-selected-keys="selectdKeys">
        <a-menu-item key="/myquestion">
          <a-icon type="user" />

          <span>我的问卷</span>
          <router-link to="/myquestion"></router-link>
        </a-menu-item>
        <a-menu-item key="/question">
          <a-icon type="form" />
          <span>创建问卷</span>
          <router-link to="/question"></router-link>
        </a-menu-item>
        <a-menu-item key="/setting">
          <a-icon type="tool" />

          <span>管理员设置</span>
          <router-link to="/setting"></router-link>
        </a-menu-item>
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0">
        <a-icon
          class="trigger"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="() => (collapsed = !collapsed)"
        />
        <a-button type="primary" @click="logout">退出</a-button>
      </a-layout-header>
      <a-layout-content>
        <router-view></router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>
<script>
import { clearUser } from "@/libs/util";
export default {
  data() {
    return {
      selectdKeys: [],
      collapsed: false
    };
  },
  created() {
    this.selectdKeys = [this.$route.path];
  },
  methods: {
    logout() {
      this.$router.push("/");
      console.log(process.env);
      clearUser();
    }
  }
};
</script>>
<style  lang="scss" scoped>
#home {
  height: 100vh;
}
#home .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#home .trigger:hover {
  color: #1890ff;
}

#home .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
  color: white;
  line-height: 32px;
  text-align: center;
}
.ant-layout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: 20px;
}
</style>
